package com.zlz.security.securitydemo1.controller;

import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zlz
 * @date: 2021/3/21 19:42
 * @description:
 * @since: JDK1.8
 */
@RestController
@RequestMapping("/test")
public class TestController {
    @GetMapping("/hello")
    public String hello() {
        return "hello world";
    }

    @GetMapping("/index")
    public String index() {
        return "hello index";
    }

    @GetMapping("/lmh")
//    @Secured({"ROLE_zlz","ROLE_manager"})
    @PreAuthorize("hasAnyAuthority('manager')")
    public String lmh() {
        return "i love you lmh";
    }
}
